import fetch from '@/utils/fetch'

// 获取库存一览
export function apiGetStockList (listQuery) {
  return fetch({
    url: '/api/v1/stock/list',
    method: 'GET',
    params: listQuery
  })
}

// 获取良品库一览
export function apiGetGoodStockList (listQuery) {
  return fetch({
    url: '/api/v1/stock/good/list',
    method: 'GET',
    params: listQuery
  })
}

// 获取维修历史一览
export function apiGetRepairHistory (listQuery) {
  return fetch({
    url: '/api/v1/stock/good/repair/history/list',
    method: 'GET',
    params: listQuery
  })
}

// 良品库转不良品
export function apiUpdateGoodToBad (listQuery) {
  return fetch({
    url: '/api/v1/stock/good/toBad',
    method: 'POST',
    data: listQuery
  })
}

// 良品库转报废品
export function apiUpdateGoodToScrap (listQuery) {
  return fetch({
    url: '/api/v1/stock/good/toScrap',
    method: 'POST',
    data: listQuery
  })
}

// 报废品转不良品
export function apiUpdateScrapToBad (listQuery) {
  return fetch({
    url: '/api/v1/stock/scrap/toBad',
    method: 'POST',
    data: listQuery
  })
}

// 报废品转良品
export function apiUpdateScrapToGood (listQuery) {
  return fetch({
    url: '/api/v1/stock/scrap/toGood',
    method: 'POST',
    data: listQuery
  })
}

// 获取维修详情
export function apiGetRepairDetail (listQuery) {
  return fetch({
    url: '/api/v1/stock/good/repair/detail',
    method: 'GET',
    params: listQuery
  })
}

// 获取不良品库一览
export function apiGetBadStockList (listQuery) {
  return fetch({
    url: '/api/v1/stock/bad/list',
    method: 'GET',
    params: listQuery
  })
}

// 获取报废库一览
export function apiGetScrapStockList (listQuery) {
  return fetch({
    url: '/api/v1/stock/scrap/list',
    method: 'GET',
    params: listQuery
  })
}

// 获取报废库一览
export function apiPostScrapBack (listQuery) {
  return fetch({
    url: '/api/v1/stock/scrap/back',
    method: 'POST',
    data: listQuery
  })
}

export function apiGetCustomerLogisticInfo (listQuery) {
  return fetch({
    url: '/api/v1/acceptOrder/customer',
    method: 'GET',
    params: listQuery
  })
}

export function apiGetFactoryLogisticInfo (listQuery) {
  return fetch({
    url: '/api/v1/factory',
    method: 'GET',
    params: listQuery
  })
}

// 网点调拨信息获取
export function apiGetPointAllotList (listQuery) {
  return fetch({
    url: '/api/v1/stock/good/allot/list',
    method: 'GET',
    params: listQuery
  })
}

// 获取可返厂一览
export function apiGetReturnFactory () {
  return fetch({
    url: '/api/v1/dictionary/supportReturnFactory/all',
    method: 'GET'
  })
}

// 不良品返厂维修
export function apiPostBadDeviceReturnFactory (listQuery) {
  return fetch({
    url: '/api/v1/stock/bad/factory',
    method: 'POST',
    data: listQuery
  })
}

export function apiInsertAllotOrder (allotOrderDTO) {
  return fetch({
    url: 'api/v1/stock/good/allot',
    method: 'POST',
    data: allotOrderDTO
  })
}

export function apiGetReceiveList (listQuery) {
  return fetch({
    url: '/api/v1/stock/good/allot/receive/list',
    method: 'GET',
    params: listQuery
  })
}

export function apiReceive (remarkDto) {
  return fetch({
    url: '/api/v1/stock/good/allot/receive',
    method: 'POST',
    data: remarkDto
  })
}

// 获取不良品库出库一览
export function apiGetBadOutstockList (listQuery) {
  return fetch({
    url: '/api/v1/stock/bad/outstock/list',
    method: 'GET',
    params: listQuery
  })
}

// 获取不良品库入库一览
export function apiGetBadInstockList (listQuery) {
  return fetch({
    url: '/api/v1/stock/bad/instock/list',
    method: 'GET',
    params: listQuery
  })
}

export function apiGetOutstockList (listQuery) {
  return fetch({
    url: '/api/v1/stock/good/outstock/list',
    method: 'GET',
    params: listQuery
  })
}

export function apiGetInstockList (listQuery) {
  return fetch({
    url: '/api/v1/stock/good/instock/list',
    method: 'GET',
    params: listQuery
  })
}

export function apiGetIOstockDetail (listQuery) {
  return fetch({
    url: '/api/v1/stock/good/iostock/detail',
    method: 'GET',
    params: listQuery
  })
}

// 库存一览表导出
export function apiExport (listQuery) {
  return fetch({
    url: '/api/v1/stock/export/all',
    method: 'post',
    data: listQuery,
    responseType: 'arraybuffer'
  })
}

export function apiGoodExport (listQuery) {
  return fetch({
    url: '/api/v1/stock/good/export',
    method: 'post',
    data: listQuery,
    responseType: 'arraybuffer'
  })
}

// 编辑良品库设备
export function apiUpdateGoodStockDevice (dto) {
  return fetch({
    url: '/api/v1/stock/good/update/device',
    method: 'put',
    data: dto
  })
}

// 编辑报废库设备
export function apiUpdateScrapStockDevice (dto) {
  return fetch({
    url: '/api/v1/stock/scrap/update/device',
    method: 'put',
    data: dto
  })
}

// 编辑不良品库设备
export function apiUpdateBadStockDevice (dto) {
  return fetch({
    url: '/api/v1/stock/bad/update/device',
    method: 'put',
    data: dto
  })
}

// 提交特殊操作申请
export function apiSpecialOperation (listQuery) {
  return fetch({
    url: '/api/v1/stock/operation',
    method: 'POST',
    data: listQuery
  })
}

// 获取所有特殊操作申请历史信息
export function apiGetSpecialOperationList (listQuery) {
  return fetch({
    url: '/api/v1/stock/operation/list',
    method: 'GET',
    params: listQuery
  })
}

// 特殊操作审核
export function apiSpecialOperationAudit (listQuery) {
  return fetch({
    url: '/api/v1/stock/operation/audit',
    method: 'POST',
    data: listQuery
  })
}

// 获取特殊操作申请详情
export function apiGetSpecialDetailList (listQuery) {
  return fetch({
    url: '/api/v1/stock/operation/detail/list',
    method: 'GET',
    params: listQuery
  })
}

// 入库一览数据导出
export function apiInstockExport (listQuery) {
  return fetch({
    url: '/api/v1/stock/export/inStock',
    method: 'POST',
    params: listQuery,
    responseType: 'arraybuffer'
  })
}

// 出库一览数据导出
export function apiOutstockExport (listQuery) {
  return fetch({
    url: 'api/v1/stock/export/outStock',
    method: 'POST',
    params: listQuery,
    responseType: 'arraybuffer'
  })
}

// 获取同一sn的报废记录
export function apiGetScrapRecord (ystsn) {
  return fetch({
    url: `api/v1/stock/scrap/record/${ystsn}`,
    method: 'GET'
  })
}
